package com.bestcem.xm.member.controller;

import com.bestcem.xm.common.core.domain.message.SampleCopyMessage;
import com.bestcem.xm.component.security.annotation.AuthIgnore;
import com.bestcem.xm.member.mq.message.RespondentDataMessage;
import com.bestcem.xm.member.service.MemberMqHandler;
import com.bestcem.xm.member.service.MemberSampleMqHandler;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 示例服务
 *
 * @author yf.wang <yf.wang@idiaoyan.com>
 * @version V1.0
 * @date 2021/8/27
 */

@RestController
@RequestMapping(value = "/mq")
public class MqTestController {

    @Resource
    private MemberMqHandler memberMqHandler;

    @Resource
    private MemberSampleMqHandler memberSampleMqHandler;

    @PostMapping(value = "/createMemberByRespondentSubmit")
    public String createMemberByRespondentSubmit(@RequestBody RespondentDataMessage data) {
        memberMqHandler.createMemberByRespondentSubmit(data);
        return "success";
    }

    @AuthIgnore
    @PostMapping(value = "/copySample")
    public String copySample(@RequestBody SampleCopyMessage data) {
        Map<String, String> ticketIdMap = new HashMap<String, String>();
        ticketIdMap.put("1", "1");
        memberSampleMqHandler.memberSampleCopy(data, ticketIdMap);
        return "success";
    }
}
